test: cancel upload by observing progress, not wall-clock sleep (flaky test) #6421
test: cancel upload by observing progress, not wall-clock sleep (flaky test) #6421FarhanAliRaza wants to merge 2 commits intoreflex-dev:mainfrom
Conversation
A fixed asyncio.sleep before clicking cancel races the browser's upload process: under CI load the test can be preempted long enough for the throttled upload to finish, after which abort() can no longer prevent the file from being written. Poll the progress display for an in-flight event (0 < progress < 1) and cancel only then.
Greptile SummaryThis PR fixes a flaky test by replacing Confidence Score: 4/5Safe to merge; test-only change with a well-designed fix for a known flaky pattern. Only one P2 style observation about diagnostics on timeout; the core logic is sound and the approach directly addresses the documented race condition. No files require special attention beyond the one P2 note on expect_upload_in_flight. Important Files Changed
Sequence DiagramsequenceDiagram
participant Test as Test (pytest)
participant Browser as Browser / WebDriver
participant DOM as DOM (progress_dicts)
participant Server as Upload Server
Test->>Browser: send_keys(target_file)
Test->>Browser: upload_button.click()
Browser->>Server: Start throttled upload (1 Mbps)
loop poll every 250ms (≤15s)
Test->>DOM: find_elements(progress_xpath)[initial_count:]
DOM-->>Test: progress entries
Test->>Test: any 0 < progress < 1?
end
Note over Test: in-flight confirmed
Test->>Browser: cancel_button.click()
Browser->>Server: abort()
Test->>Test: asyncio.sleep(12) — upload would finish if cancel failed
Test->>DOM: find_elements(progress_xpath)[initial_count:]
DOM-->>Test: progress entries
Test->>Test: assert no progress == 1
Test->>Server: assert file not written
Reviews (1): Last reviewed commit: "test: cancel upload by observing progres..." | Re-trigger Greptile |
|
supersede by #6424 with various improvements |
A fixed asyncio.sleep before clicking cancel races the browser's upload process: under CI load the test can be preempted long enough for the throttled upload to finish, after which abort() can no longer prevent the file from being written. Poll the progress display for an in-flight event (0 < progress < 1) and cancel only then.
All Submissions: